package com.yuneec.fly.models;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

/**
 * Created by lk.sun on 6/21/2016.
 */
public class ConnectResource implements Parcelable, Serializable {
    private String cameraUrl;
    private String language;
    private byte isMetricUnit;  // 1: Metric unit, 0: Imperial
    private byte isUsedMainboardGps; // 1: Used mainboard GPS, 0: Used M4 GPS
    private int analogChannelNumber;
    private int switchChannelNumber;
    private byte[] radioResource;
    private int channelConfigListSize;

    public int getChannelConfigListSize() {
        return channelConfigListSize;
    }

    public void setChannelConfigListSize(int channelConfigListSize) {
        this.channelConfigListSize = channelConfigListSize;
    }

    public int getAnalogChannelNumber() {
        return analogChannelNumber;
    }

    public void setAnalogChannelNumber(int analogChannelNumber) {
        this.analogChannelNumber = analogChannelNumber;
    }

    public int getSwitchChannelNumber() {
        return switchChannelNumber;
    }

    public void setSwitchChannelNumber(int switchChannelNumber) {
        this.switchChannelNumber = switchChannelNumber;
    }

    public String getCameraUrl() {
        return cameraUrl;
    }

    public void setCameraUrl(String cameraUrl) {
        this.cameraUrl = cameraUrl;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public byte getIsMetricUnit() {
        return isMetricUnit;
    }

    public void setIsMetricUnit(byte isMetricUnit) {
        this.isMetricUnit = isMetricUnit;
    }

    public byte getIsUsedMainboardGps() {
        return isUsedMainboardGps;
    }

    public void setIsUsedMainboardGps(byte isUsedMainboardGps) {
        this.isUsedMainboardGps = isUsedMainboardGps;
    }

    public byte[] getRadioResource() {
        return radioResource;
    }

    public void setRadioResource(byte[] radioResource) {
        this.radioResource = radioResource;
    }

    public ConnectResource() {
    }

    protected ConnectResource(Parcel in) {
        cameraUrl = in.readString();
        language = in.readString();
        isMetricUnit = in.readByte();
        isUsedMainboardGps = in.readByte();
        analogChannelNumber = in.readInt();
        switchChannelNumber = in.readInt();

        byte[] ba = in.createByteArray();
        if (ba != null) {
            radioResource = new byte[ba.length];
            System.arraycopy(ba, 0, radioResource, 0, ba.length);
        } else {
            radioResource = new byte[1];
        }
        channelConfigListSize = in.readInt();
    }

    public static final Creator<ConnectResource> CREATOR = new Creator<ConnectResource>() {
        @Override
        public ConnectResource createFromParcel(Parcel in) {
            return new ConnectResource(in);
        }

        @Override
        public ConnectResource[] newArray(int size) {
            return new ConnectResource[size];
        }
    };

    /**
     * Describe the kinds of special objects contained in this Parcelable's
     * marshalled representation.
     *
     * @return a bitmask indicating the set of special object types marshalled
     * by the Parcelable.
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * Flatten this object in to a Parcel.
     *
     * @param dest  The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written.
     *              May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(cameraUrl);
        dest.writeString(language);
        dest.writeByte(isMetricUnit);
        dest.writeByte(isUsedMainboardGps);
        dest.writeInt(analogChannelNumber);
        dest.writeInt(switchChannelNumber);
        dest.writeByteArray(radioResource);
        dest.writeInt(channelConfigListSize);
    }
}
